package guda.house.web.action.bill;

import guda.grape.util.RequestUtil;
import guda.house.biz.beans.vo.JsonResult;
import guda.house.biz.bo.EstateFeeBO;
import guda.house.biz.constants.CommonResultCode;
import guda.house.biz.util.ErrorCode;
import guda.house.web.helper.ResponseHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by well on 15/11/16.
 */
@Controller
@RequestMapping(value = "bill/estate")
public class BillEstateAction {

    @Autowired
    private EstateFeeBO estateFeeBO;

    @RequestMapping(value = "/list.htm", method = RequestMethod.GET)
    public String list(HttpServletRequest request, ModelMap modelMap) {

        return "bill/estate/list.vm";

    }

    @RequestMapping(value = "state.htm")
    public void getBuilding(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) {
        long villageId = RequestUtil.getLong(request, "villageId");
        JsonResult result = JsonResult.getInstance();
        if (villageId == 0) {
            result.setErrMsg(ErrorCode.getMessage(CommonResultCode.PARAM_MISS));
            ResponseHelper.ajaxReturn(result.getMap(), response);
            return;
        }

        String stateResult = estateFeeBO.stateFee(villageId);

        result.getMap().put("stateResult", stateResult);
        ResponseHelper.ajaxReturn(result.getMap(), response);

    }
}
